<template>
  <div class="container">

      <!-- 默认插槽 -->
      <!-- <slot></slot> -->

      <!-- 具名插槽 -->
      <button @click="str='tab1'">tab1</button>
      <button @click="str='tab2'">tab2</button>
      <slot :name="str"></slot>
      
       <!-- 作用域插槽 子传父-->
    <slot :arr="arr"></slot>
    <br><br>
       <div id="on">
            <h2>兄弟组件互相传值通信</h2>
             
            <p>8888886666---{{message}}</p>
      
        </div>
  </div>
</template>

<script>
 import Bus from './bus'
export default {
  data() {
    return {
        str:'tab1',
        arr:[
            {
              user:'张三',
              school:'二小',
              age:12
            },
            {
              user:'李四',
              school:'一中',
              age:15,
            },
             {
              user:'王五',
              school:'一高',
              age:18,
            }

        ],
        message:'',
    }
  },
  methods:{

  },
  components: {

  },
    mounted() {
      let self = this;
       Bus.$on('msg', (e) => {
         self.message = e;
        console.log(`传来的数据是：${e}`)
      
       })
     }
   }

</script>

<style scoped>

</style>
